import {inject, observer} from 'mobx-react';
import * as mobx from 'mobx';
import {WeaLocaleProvider, WeaSearchGroup} from "ecCom";
import MainFieldLogs from "./MainFieldLogs";
import DetailFieldLogs from "./DetailFieldLogs";
const getLabel = WeaLocaleProvider.getLabel;

export default class Main extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        let mainChangeLog = [], detailChangeLog = {};
        const {hasMain, hasDetail, detailTableList, checkResult} = this.props;

        if (hasMain) {
            mainChangeLog = this.props.mainChangeLog;
        }

        if (hasDetail) {
            detailChangeLog = this.props.detailChangeLog;
        }

        if (hasMain || hasDetail) {
            return (
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@ieju4z`} showGroup={true} title={getLabel(501205, "保护字段")}>
                    {hasMain && <MainFieldLogs ecId={`${this && this.props && this.props.ecId || ''}_MainFieldLogs@85yd8w`} datas={[...mainChangeLog]} checkResult={checkResult}/>}
                    {hasDetail && <DetailFieldLogs ecId={`${this && this.props && this.props.ecId || ''}_DetailFieldLogs@33wz44`} datas={{...detailChangeLog}} tables={[...detailTableList]} checkResult={checkResult}/>}
                </WeaSearchGroup>
            );
        } else {
            return null;
        }
    }
}